package com.hyts.standard.webflux.r2db.service;

import com.hyts.standard.webflux.bean.po.UserPO;
import com.hyts.standard.webflux.r2db.dao.UsersDao;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wayne
 * @version UsersService,  2020/9/13
 */
@Component
public class UsersService {

    /**
     * 用户数据访问层
     */
    @Resource
    private UsersDao usersDao;

    /**
     * 查询数据信息
     * @param userName
     * @return
     */
//    @Transactional
    public Flux<UserPO> search(String userName) {
        return usersDao.findAllByUserName(userName);
    }



//    @Transactional
    public Mono<UserPO> save(String userName) {
        UserPO userPO = new UserPO();
        userPO.setUserName(userName);
        userPO.setRealName(userName);
        return usersDao.save(userPO);
    }


}
